﻿using GraphProcessor;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Level + "/" + LevelEditorConst.LevelService + LevelEditorConst.Prefab, typeof(LevelServiceGraph))]
    public class LevelServiceNode_Prefab : IDGenerateNode
    {
        public override bool isRenamable => true;
        public override Color color => Color.green;
        public override string name => LevelEditorConst.LevelService + LevelEditorConst.Prefab;

        [Input("开始", false), Vertical] public EditorLevelServiceConfig serveiceGroup;
        [Output("下一服务", false), Vertical] public EditorLevelServiceConfig next;

        [LevelServicePrefabDropdown(1)]
        public string prefab;

        protected override void Process()
        {
            if (this.serveiceGroup == null)
            {
                return;
            }
            base.Process();
            var rServiceConfig = new EditorLevelServiceUnitConfig()
            {
                prefabKey = this.prefab,
                name = this.GetCustomName()
            };
            this.serveiceGroup.serviceUnits.Add(rServiceConfig);
            this.next = this.serveiceGroup;
        }
    }
}